enum NetResponseCode {
  success,
  networkError, //网络无连接
  timeout, //超时
  cancel, //取消
  invalidToken, //token失效
  freezeAccount, //账号封禁
  parsingError, //解析错误
  unknow;

  static NetResponseCode getCode(int? code, int? status) {
    if (status == 10002) {
      return NetResponseCode.invalidToken;
    } else if (code == 0 || status == 200) {
      return NetResponseCode.success;
    } else if (status == 401) {
      //token 失效 清除token
      return NetResponseCode.invalidToken;
    } else {
      switch (code) {
        case 401:
          //token 失效 清除token
          return NetResponseCode.invalidToken;
        default:
          return NetResponseCode.unknow;
      }
    }
  }
}
